package com.example.javamediaserver.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.nio.file.Path;
import java.nio.file.Paths;

@Configuration
@ConfigurationProperties(prefix = "media")
@Data
public class MediaServerConfig {

    private RtmpConfig rtmp = new RtmpConfig();
    private HttpConfig http = new HttpConfig();
    private HlsConfig hls = new HlsConfig();
    private RecordingsConfig recordings = new RecordingsConfig();

    @Data
    public static class RtmpConfig {
        private int port = 1935;
        private int chunkSize = 60000;
        private boolean gopCache = true;
        private int ping = 30;
        private int pingTimeout = 60;
    }

    @Data
    public static class HttpConfig {
        private int port = 8000;
        private String allowOrigin = "*";
    }

    @Data
    public static class HlsConfig {
        private int segmentDuration = 2;
        private int playlistSize = 5;
        private String path = "media/hls";

        public Path getAbsolutePath() {
            return Paths.get(path).toAbsolutePath();
        }
    }

    @Data
    public static class RecordingsConfig {
        private boolean enabled = true;
        private String path = "media/recordings";

        public Path getAbsolutePath() {
            return Paths.get(path).toAbsolutePath();
        }
    }
} 